#include "bits.h"

int bitGet(unsigned char x, int pos) {
	return (x & (1 << pos)); 
}

int bitSet(unsigned char x, int pos) {
	return (x | (1 << pos));
}

int bitClear(unsigned char x, int pos) {
	return (x & ~ (1 << pos));
}

int bitArrayGet(unsigned char *state, int pos) {
	return bitGet(state[7 - pos / 8], pos % 8);
}

void bitArraySet(unsigned char *state, int pos) {
	state[7 - pos / 8] = bitSet(state[7 - pos / 8], pos % 8);
}

void bitArrayClear(unsigned char *state, int pos) {
	state[7 - pos / 8] = bitClear(state[7 - pos / 8], pos % 8);
}
